home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <GL/glx.h>
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <X11/keysym.h>
-
- static int RGB_attributes_DB[] = {
- GLX_RGBA,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_DOUBLEBUFFER,
- None,
- };
-
- static int CI_attributes_DB[] = {
- GLX_DOUBLEBUFFER,
- None,
- };
-
- static int RGB_attributes[] = {
- GLX_RGBA,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- None,
- };
-
- static int CI_attributes[] = {
- None,
- };
-
- int rgb = 0;
- int W = 300;
- int H = 300;
- int doubleBuf = 1;
- GLXContext cx, cx2;
- Window window, window2;
- Display *dpy;
-
- unsigned char font6x10[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x10, 0x38, 0x38, 0x7c, 0x38, 0x38, 0x10, 0x00,
- 0x00, 0x00, 0x54, 0x28, 0x54, 0x28, 0x54, 0x28, 0x54, 0x00,
- 0x08, 0x08, 0x08, 0x3c, 0x48, 0x48, 0x78, 0x48, 0x48, 0x00,
- 0x10, 0x10, 0x18, 0x10, 0x5c, 0x40, 0x60, 0x40, 0x70, 0x00,
- 0x24, 0x24, 0x38, 0x24, 0x38, 0x38, 0x40, 0x40, 0x38, 0x00,
- 0x20, 0x20, 0x38, 0x20, 0x3c, 0x78, 0x40, 0x40, 0x40, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x28, 0x28, 0x38, 0x00,
- 0x00, 0x00, 0x7c, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x00, 0x00,
- 0x3c, 0x20, 0x20, 0x20, 0x48, 0x58, 0x68, 0x68, 0x48, 0x00,
- 0x08, 0x08, 0x08, 0x08, 0x3c, 0x20, 0x30, 0x48, 0x48, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x1c, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x10, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x1c, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x10, 0x10, 0x10, 0x10,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x10, 0x10, 0x10, 0x10,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
- 0x00, 0x7c, 0x04, 0x08, 0x20, 0x40, 0x20, 0x08, 0x04, 0x00,
- 0x00, 0x7c, 0x40, 0x20, 0x08, 0x04, 0x08, 0x20, 0x40, 0x00,
- 0x00, 0x00, 0x28, 0x28, 0x28, 0x28, 0x7c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x20, 0x7c, 0x10, 0x7c, 0x08, 0x04, 0x00,
- 0x00, 0x20, 0x6c, 0x38, 0x20, 0x78, 0x20, 0x24, 0x18, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x28, 0x28, 0x00,
- 0x00, 0x00, 0x28, 0x28, 0x7c, 0x28, 0x7c, 0x28, 0x28, 0x00,
- 0x00, 0x00, 0x10, 0x38, 0x14, 0x38, 0x50, 0x38, 0x10, 0x00,
- 0x00, 0x00, 0x48, 0x54, 0x28, 0x10, 0x28, 0x54, 0x24, 0x00,
- 0x00, 0x00, 0x34, 0x48, 0x54, 0x20, 0x50, 0x50, 0x20, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x18, 0x00,
- 0x00, 0x00, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x00,
- 0x00, 0x00, 0x20, 0x10, 0x08, 0x08, 0x08, 0x10, 0x20, 0x00,
- 0x00, 0x00, 0x00, 0x44, 0x28, 0x7c, 0x28, 0x44, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x00, 0x00,
- 0x00, 0x20, 0x10, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x10, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x40, 0x20, 0x10, 0x08, 0x04, 0x04, 0x00,
- 0x00, 0x00, 0x10, 0x28, 0x44, 0x44, 0x44, 0x28, 0x10, 0x00,
- 0x00, 0x00, 0x7c, 0x10, 0x10, 0x10, 0x50, 0x30, 0x10, 0x00,
- 0x00, 0x00, 0x7c, 0x40, 0x20, 0x18, 0x04, 0x44, 0x38, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x04, 0x18, 0x08, 0x04, 0x7c, 0x00,
- 0x00, 0x00, 0x08, 0x08, 0x7c, 0x48, 0x28, 0x18, 0x08, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x04, 0x64, 0x58, 0x40, 0x7c, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x64, 0x58, 0x40, 0x20, 0x18, 0x00,
- 0x00, 0x00, 0x20, 0x20, 0x10, 0x08, 0x08, 0x04, 0x7c, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x38, 0x00,
- 0x00, 0x00, 0x30, 0x08, 0x04, 0x34, 0x4c, 0x44, 0x38, 0x00,
- 0x00, 0x10, 0x38, 0x10, 0x00, 0x10, 0x38, 0x10, 0x00, 0x00,
- 0x00, 0x20, 0x10, 0x18, 0x00, 0x10, 0x38, 0x10, 0x00, 0x00,
- 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x20, 0x10, 0x08, 0x10, 0x20, 0x40, 0x00,
- 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x08, 0x44, 0x38, 0x00,
- 0x00, 0x00, 0x38, 0x40, 0x58, 0x54, 0x4c, 0x44, 0x38, 0x00,
- 0x00, 0x00, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x28, 0x10, 0x00,
- 0x00, 0x00, 0x78, 0x24, 0x24, 0x38, 0x24, 0x24, 0x78, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, 0x00,
- 0x00, 0x00, 0x78, 0x24, 0x24, 0x24, 0x24, 0x24, 0x78, 0x00,
- 0x00, 0x00, 0x7c, 0x40, 0x40, 0x78, 0x40, 0x40, 0x7c, 0x00,
- 0x00, 0x00, 0x40, 0x40, 0x40, 0x78, 0x40, 0x40, 0x7c, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x4c, 0x40, 0x40, 0x44, 0x38, 0x00,
- 0x00, 0x00, 0x44, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x44, 0x00,
- 0x00, 0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x04, 0x04, 0x04, 0x04, 0x1c, 0x00,
- 0x00, 0x00, 0x44, 0x48, 0x50, 0x60, 0x50, 0x48, 0x44, 0x00,
- 0x00, 0x00, 0x7c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00,
- 0x00, 0x00, 0x44, 0x44, 0x44, 0x54, 0x6c, 0x44, 0x44, 0x00,
- 0x00, 0x00, 0x44, 0x44, 0x4c, 0x54, 0x64, 0x44, 0x44, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00,
- 0x00, 0x00, 0x40, 0x40, 0x40, 0x78, 0x44, 0x44, 0x78, 0x00,
- 0x00, 0x04, 0x38, 0x54, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00,
- 0x00, 0x00, 0x44, 0x48, 0x50, 0x78, 0x44, 0x44, 0x78, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x04, 0x38, 0x40, 0x44, 0x38, 0x00,
- 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00,
- 0x00, 0x00, 0x10, 0x28, 0x28, 0x28, 0x44, 0x44, 0x44, 0x00,
- 0x00, 0x00, 0x44, 0x6c, 0x54, 0x54, 0x44, 0x44, 0x44, 0x00,
- 0x00, 0x00, 0x44, 0x44, 0x28, 0x10, 0x28, 0x44, 0x44, 0x00,
- 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x28, 0x44, 0x44, 0x00,
- 0x00, 0x00, 0x7c, 0x40, 0x20, 0x10, 0x08, 0x04, 0x7c, 0x00,
- 0x00, 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00,
- 0x00, 0x00, 0x04, 0x04, 0x08, 0x10, 0x20, 0x40, 0x40, 0x00,
- 0x00, 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x28, 0x10, 0x00,
- 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x30, 0x00,
- 0x00, 0x00, 0x3c, 0x44, 0x3c, 0x04, 0x38, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x58, 0x64, 0x44, 0x64, 0x58, 0x40, 0x40, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x34, 0x4c, 0x44, 0x4c, 0x34, 0x04, 0x04, 0x00,
- 0x00, 0x00, 0x38, 0x40, 0x7c, 0x44, 0x38, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x20, 0x20, 0x20, 0x78, 0x20, 0x24, 0x18, 0x00,
- 0x38, 0x44, 0x38, 0x40, 0x30, 0x48, 0x34, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x44, 0x44, 0x44, 0x64, 0x58, 0x40, 0x40, 0x00,
- 0x00, 0x00, 0x38, 0x10, 0x10, 0x10, 0x30, 0x00, 0x10, 0x00,
- 0x30, 0x48, 0x48, 0x08, 0x08, 0x08, 0x18, 0x00, 0x08, 0x00,
- 0x00, 0x00, 0x44, 0x48, 0x70, 0x48, 0x44, 0x40, 0x40, 0x00,
- 0x00, 0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x30, 0x00,
- 0x00, 0x00, 0x44, 0x54, 0x54, 0x54, 0x68, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x44, 0x44, 0x44, 0x64, 0x58, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00,
- 0x40, 0x40, 0x40, 0x58, 0x64, 0x64, 0x58, 0x00, 0x00, 0x00,
- 0x04, 0x04, 0x04, 0x34, 0x4c, 0x4c, 0x34, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x40, 0x40, 0x40, 0x64, 0x58, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x78, 0x04, 0x38, 0x40, 0x38, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x18, 0x24, 0x20, 0x20, 0x78, 0x20, 0x20, 0x00,
- 0x00, 0x00, 0x34, 0x4c, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x10, 0x28, 0x28, 0x44, 0x44, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x28, 0x54, 0x54, 0x44, 0x44, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00,
- 0x38, 0x44, 0x04, 0x34, 0x4c, 0x44, 0x44, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x7c, 0x20, 0x10, 0x08, 0x7c, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x0c, 0x10, 0x08, 0x30, 0x08, 0x10, 0x0c, 0x00,
- 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00,
- 0x00, 0x00, 0x60, 0x10, 0x20, 0x18, 0x20, 0x10, 0x60, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x54, 0x24, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
-
- int fontbase = 256;
-
- #define MAX_COLORS 15
-
- float colors[MAX_COLORS][3] = {
- { 1.0, 0.0, 0.0 },
- { 0.8, 0.2, 0.0 },
- { 0.6, 0.4, 0.0 },
- { 0.4, 0.6, 0.0 },
- { 0.2, 0.8, 0.0 },
- { 0.0, 1.0, 0.0 },
- { 0.0, 0.8, 0.2 },
- { 0.0, 0.6, 0.4 },
- { 0.0, 0.4, 0.6 },
- { 0.0, 0.2, 0.8 },
- { 0.0, 0.0, 1.0 },
- { 0.2, 0.0, 0.8 },
- { 0.4, 0.0, 0.6 },
- { 0.6, 0.0, 0.4 },
- { 0.8, 0.0, 0.2 },
- };
-
- void initializeFont(void)
- {
- int i;
-
- glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- for (i=0; i<128; i++) {
- glNewList(i+fontbase, GL_COMPILE);
- glBitmap(6, 10, 0.0, 0.0, 6.0, 0.0, font6x10+10*i);
- glEndList();
- }
- }
-
- void writeFont(char *string)
- {
- glListBase(fontbase);
- glCallLists(strlen(string), GL_BYTE, (unsigned char *) string);
- }
-
- static void Init(void)
- {
- glViewport(0,0,W,H);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0,W,0,H,-1,1);
- glMatrixMode(GL_MODELVIEW);
-
- if (rgb) {
- glClearColor(0,0,0,0);
- } else {
- glClearIndex(0);
- }
-
- glClear(GL_COLOR_BUFFER_BIT);
-
- initializeFont();
- }
-
- static void Redraw(void)
- {
- int i, y;
- static int color;
-
- color = (color+1) % MAX_COLORS;
- for (i=0; i<2; i++) {
- if (i == 0) {
- glXMakeCurrent(dpy, window, cx);
- } else {
- glXMakeCurrent(dpy, window2, cx);
- }
-
- if (rgb) {
- glColor3fv(colors[color]);
- } else {
- glIndexi(color);
- }
-
- glClear(GL_COLOR_BUFFER_BIT);
-
- glRasterPos2i(5, 50);
- writeFont("Hello");
- sginap(10);
- glRasterPos2i(5, 40);
- writeFont("There");
- sginap(10);
- glRasterPos2i(5, 30);
- writeFont("World");
-
- if (doubleBuf) {
- if (i == 0) {
- glXSwapBuffers(dpy, window);
- } else {
- glXSwapBuffers(dpy, window2);
- }
- }
- }
- }
-
- static void Usage(void)
- {
- fprintf(stderr, "Usage: wind2 [-c] [-s]\n");
- fprintf(stderr, " -c run in color index mode\n");
- fprintf(stderr, " -s run in singlebuffer mode\n");
- exit(1);
- }
-
- static Bool WaitForMapNotify(Display *d, XEvent *e, char *arg)
- {
- if ((e->type == MapNotify) && (e->xmap.window == (Window) arg)) {
- return GL_TRUE;
- }
- return GL_FALSE;
- }
-
- int main(int argc, char** argv)
- {
- XVisualInfo *vi;
- Colormap cmap;
- XSetWindowAttributes swa;
- XEvent event;
- XColor white;
- int i;
-
- rgb = 1;
- doubleBuf = 1;
- for (i = 1; i < argc; i++) {
- if (argv[i][0] == '-') {
- switch (argv[i][1]) {
- case 'c':
- rgb = GL_FALSE;
- break;
- case 's':
- doubleBuf = 0;
- break;
- default:
- Usage();
- }
- } else {
- Usage();
- }
- }
-
- dpy = XOpenDisplay(0);
- if (!dpy) {
- fprintf(stderr, "Can't connect to display \"%s\"\n", getenv("DISPLAY"));
- return -1;
- }
-
- vi = glXChooseVisual(dpy, DefaultScreen(dpy),
- doubleBuf ?
- (rgb ? RGB_attributes_DB : CI_attributes_DB) :
- (rgb ? RGB_attributes : CI_attributes));
- if (!vi) {
- fprintf(stderr, "No singlebuffered rgba visual on \"%s\"\n",
- getenv("DISPLAY"));
- return -1;
- }
-
- printf("Drawing with one context, two windows.\n");
- if (rgb) {
- printf("rgb mode, ");
- } else {
- printf("color index mode, ");
- }
- if (doubleBuf) {
- printf("double buffered\n");
- } else {
- printf("single buffered\n");
- }
-
- cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual,
- rgb ? AllocNone : AllocAll);
- if (rgb) {
- white.red = ~0;
- white.green = ~0;
- white.blue = ~0;
- XAllocColor(dpy, cmap, &white);
- swa.background_pixel = white.pixel;
- } else {
- swa.background_pixel = 15;
- }
-
- if (!rgb) {
- XColor buf;
- int i;
-
- buf.flags = DoRed | DoGreen | DoBlue;
-
- /* Init color map */
- for (i=0; i<16; i++) {
- buf.pixel = i;
- buf.red = (i & 4) ? 65535 : 0;
- buf.green = (i & 2) ? 65535 : 0;
- buf.blue = (i & 1) ? 65535 : 0;
- XStoreColor(dpy, cmap, &buf);
- }
- }
-
- swa.border_pixel = 0;
- swa.colormap = cmap;
- swa.event_mask = ExposureMask | StructureNotifyMask | KeyPressMask
- | KeyReleaseMask;
- window = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 10, 10,
- W, H,
- 0, vi->depth, InputOutput, vi->visual,
- CWBackPixel|CWBorderPixel|CWColormap|CWEventMask,
- &swa);
- XSetWMColormapWindows(dpy, window, &window, 1);
- XMapWindow(dpy, window);
- XIfEvent(dpy, &event, WaitForMapNotify, (char*)window);
-
- window2 = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 10, 10,
- W, H,
- 0, vi->depth, InputOutput, vi->visual,
- CWBackPixel|CWBorderPixel|CWColormap|CWEventMask,
- &swa);
- XSetWMColormapWindows(dpy, window2, &window2, 1);
- XMapWindow(dpy, window2);
- XIfEvent(dpy, &event, WaitForMapNotify, (char*)window2);
-
- cx = glXCreateContext(dpy, vi, 0, GL_TRUE);
- if (!glXMakeCurrent(dpy, window, cx)) {
- fprintf(stderr, "Can't make window current to context\n");
- return -1;
- }
- Init();
-
- for (;;) {
- if (XPending(dpy)) do {
- XNextEvent(dpy, &event);
- switch (event.type) {
- case Expose:
- break;
- case ConfigureNotify:
- W = event.xconfigure.width;
- H = event.xconfigure.height;
- glViewport(0,0,W,H);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0,W,0,H,-1,1);
- glMatrixMode(GL_MODELVIEW);
- glClear(GL_COLOR_BUFFER_BIT);
- break;
- case KeyPress:
- {
- char buf[100];
- int rv;
- KeySym ks;
-
- rv = XLookupString(&event.xkey, buf, sizeof(buf), &ks, 0);
- switch (ks) {
- case XK_F: case XK_f:
- case XK_S: case XK_s:
- case XK_P: case XK_p:
- case XK_L: case XK_l:
- case XK_C: case XK_c:
- break;
- case XK_Escape:
- return 0;
- default:
- break;
- }
- }
- break;
- }
- } while (XPending(dpy) != 0);
-
- Redraw();
- }
- }
-